<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/include/taglibs.jsp"%>
<script type="text/javascript">

$(document).ready(function(){
	<c:if test="${param.returnCd=='0000' }">alert('수정했습니다');</c:if>	
});

//데이터 저장
function submitData(){
	if($("#p_logo").val()!=''){
		
		$("#del_p_logo").attr("checked",true);
	}
	if($("#footer_logo").val()!=''){
		$("#del_footer_logo").attr("checked",true);
	}
	alert($("#frmData").attr("method"));
	$("#frmData").submit();
}

//순서변경
function changeOrder(idx, ord){
	
// 	<input id="pr_no${status.index }" value="${map.pr_no }" type="hidden"/>
// 	<input id="room_ord${status.index }" value="${map.room_ord }" type="hidden"/>
	var sum = Number(idx)+Number(ord);
// 	alert("pr_no : "+$("#pr_no"+idx).val()+", room_ord : "+$("#room_ord"+idx).val()+", ch_pr_no : "+$("#pr_no"+sum).val()+", room_ord : "+$("#room_ord"+sum).val());
	location.href="./peti503T.do?p_id=${map.p_id}&pr_no="+$("#pr_no"+idx).val()+"&room_ord="+$("#room_ord"+sum).val()+"&ch_pr_no="+$("#pr_no"+sum).val()+"&ch_room_ord="+$("#room_ord"+idx).val();
}

//사이트 복사
function copyRoom(cnt){
	
	if($("input[name='cp_pr_no']:checked").length>1){
		alert("복사할 사이트을 하나만 선택하세요");
		return false;
	}
	if($("input[name='cp_pr_no']:checked").length==0){
		alert("복사할 사이트을 선택하세요");
		return false;
	}
	if(confirm("복사하시겠습니까?")){
		location.href="./petc0109T.do?p_id=${map.p_id}&pr_no="+$("input[name='cp_pr_no']:checked:eq(0)").val()+"&cnt="+cnt;	
	}
}

//사이트명 저장
function saveName(){
	if(confirm("저장하시겠습니까?")){
// 		location.href="./petc0110T.do?p_id=${map.p_id}&pr_no="+pr_no+"&room_nm="+$("#"+nm).val();
		
		var html = "";
		$(".names").each(function (){
			var pr_no = $(this).find("input[name='pr_no']").val();
			var room_nm = $(this).find("input[name='room_nm']").val();
			html+="<input name='pr_nos' type='text' value='"+pr_no+"'/>";
			html+="<input name='room_nms' type='text' value='"+room_nm+"'/>";
		});
		html+="<input name='p_id' type='text' value='${map.p_id}'/>";
		$("#frmData").html(html);
		$("#frmData").submit();
	}
}

//선택 삭제
function selDel(){
	if($("input[name='cp_pr_no']:checked").length>0){
		if(confirm("삭제하시겠습니까?")){
			var html = "";
			$("input[name='cp_pr_no']:checked").each(function (){
				html+="<input name='pr_nos' type='text' value='"+$(this).val()+"'/>";
			});
			html+="<input name='p_id' type='text' value='${map.p_id}'/>";
			$("#frmData").html(html);
			$("#frmData").attr("action","./petc0113T.do");
// 			alert($("#frmData").attr("action","./petc0113T.do"));
			$("#frmData").submit();	
		}
	}else{
		alert("삭제할 사이트를 선택하세요");
	}
}
</script>
<%@ include file="/WEB-INF/jsp/pmgr/pe/ti/page_top.jsp"%>

<form id="frmData" action="./petc0110T.do" method="post" style="display: none;">

</form>

<table width="800" >
<tr>
	<td align="left">사이트목록</td>
	<td align="right">
		<b><a href="#" onclick="saveName();">
		[저장]
		</a>
		</b>
		<b><a href="#" onclick="selDel();">
		[선택삭제]
		</a>
		</b>
		<b><a href="./peti501Q.do?p_id=${param.p_id }">[사이트등록]</a></b>
		<b><a href="#" onclick="copyRoom(1);">[복사]</a></b>
		<b><a href="#" onclick="copyRoom(5);">[5사이트 복사]</a></b>
		<b><a href="#" onclick="copyRoom(10);">[10사이트 복사]</a></b>
		<b><a href="./petc0114Q.do?p_id=${param.p_id }">[순서설정]</a></b>
	</td>
</tr>
</table>
<table width="800" border="0"  cellspacing="1" cellpadding="2" CLASS="class_admin_table">
<tr height="25" class="class_admin_table_head">
	<td align="center" width="35">복사</td>
	<td align="center" width="120">사이트명</td>
	<td align="center" width="100">그룹</td>
	<td align="center" width="80">사이트구분</td>
	<td align="center">기본인원</td>
	<td align="center">최대인원</td>
	<td align="center">면적(가로/세로)</td>
	<td align="center">사이트형태</td>
<!-- 	<td align="center">금액</td> -->
	<td align="center">순서</td>
</tr>
<c:if test="${list !=null && fn:length(list)>0 }">
	<c:forEach var="map" items="${list}" varStatus="status">
<tr height="25" class="class_admin_table_blank">
	<td align="center">
		<input name="cp_pr_no" type="checkbox" value="${map.pr_no}">
	</td>
	<td align="center" class="names">
		<input id="pr_no${status.index }" name="pr_no" value="${map.pr_no }" type="hidden"/>
		<input id="room_ord${status.index }" value="${map.room_ord }" type="hidden"/>
		<input name="room_nm" id="nm_${status.index }" value="${map.room_nm }" type="text" style="padding-left: 2px;"/>
	</td>
	<td align="center">
		<a href="./peti502Q.do?p_id=${param.p_id }&pr_no=${map.pr_no}">${map.pg_no_nm }</a>
	</td>
	<td align="center">
		<a href="./peti502Q.do?p_id=${param.p_id }&pr_no=${map.pr_no}">
		<c:if test="${map.room_type=='F' }">가족룸</c:if>
		<c:if test="${map.room_type=='C' }">커플룸</c:if>
		<c:if test="${map.room_type=='B' }">단체룸</c:if>
		</a>
	</td>
	<td align="center">${map.use_man_cnt }</td>
	<td align="center">${map.use_max_cnt }</td>
	<td align="center">${map.area_p }/${map.area_m }</td>
	<td align="center">${map.room_form }</td>
<%-- 	<td align="center">${map.busy_1_base },000</td> --%>
	<td align="center">
		<c:if test="${status.index!=0 }">
		<a href="#" onclick="changeOrder('${status.index }',-1);">위로</a>
		</c:if>
		<c:if test="${fn:length(list)!=status.count }">
		<a href="#" onclick="changeOrder('${status.index }',1);">아래로</a>
		</c:if>
	</td>
</tr>
	</c:forEach>
</c:if>

</table>


<table width="700" border="0"  cellspacing="1" cellpadding="2" CLASS="class_admin_table_nocolor">
<tr> 
	<td height="25"  align="center">
	<INPUT TYPE="button" onclick="location.href='./peti100Q.do'" value=" 펜 션 목 록 "> 
	</td>
</tr>
</table>	

